package com.yyyzzz.servlet;

import com.yyyzzz.service.impl.teacherServiceImpl;
import com.yyyzzz.service.teacherService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/*@WebServlet("/selectTeacherByCourseTeacherServlet")*/
public class selectTeacherByCourseTeacherServlet extends HttpServlet {
    @Override
    protected void doGet (HttpServletRequest req , HttpServletResponse resp) throws ServletException, IOException {
        teacherService teacherService = new teacherServiceImpl ();
        String name = req.getParameter ("name");
        try {
            List list = teacherService.selectCourseTeacher (name);
            if ( list==null ){
                resp.getWriter ().write ("暂未发布"+name+"该教师的课程信息！");
            }else {
                req.setAttribute ("name",name);
                req.getRequestDispatcher ("teacherCourse.jsp").forward (req,resp);
            }
        } catch (Exception e) {
            e.printStackTrace ();
        }
    }

    @Override
    protected void doPost (HttpServletRequest req , HttpServletResponse resp) throws ServletException, IOException {
       doGet (req , resp);
    }
}
